const pool = require('../config/db');

const Follower = {
    async create({ follower_id, following_id }) {
        await pool.query(
            'INSERT INTO followers (follower_id, following_id) VALUES (?, ?)',
            [follower_id, following_id]
        );
    },

    async delete(follower_id, following_id) {
        await pool.query(
            'DELETE FROM followers WHERE follower_id = ? AND following_id = ?',
            [follower_id, following_id]
        );
    },

    async exists(follower_id, following_id) {
        const [rows] = await pool.query(
            'SELECT 1 FROM followers WHERE follower_id = ? AND following_id = ?',
            [follower_id, following_id]
        );
        return rows.length > 0;
    }
};

module.exports = Follower;